package cn.tedu.knows.search.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Data
@Accessors(chain = true)
@AllArgsConstructor  //全参构造
@NoArgsConstructor  //无参构造
/*操作索引时,如果索引不存在,SpringData会自动创建该索引*/
@Document(indexName = "items")
public class Item {
    @Id
    private Long id;
    @Field(type = FieldType.Text,
            analyzer = "ik_smart",
            searchAnalyzer = "ik_smart")
    private String title; //标题

    @Field(type = FieldType.Keyword)
    private String category; //分类

    @Field(type = FieldType.Keyword)
    private String brand; //品牌

    @Field(type = FieldType.Double)
    private Double price; //价格

    //index=false 表示不会对这个列的内容创建索引
    //一般用于不会作为查询条件的属性\列,能节省空间
    @Field(type = FieldType.Keyword,index = false)
    private String images; //图片地址

}
